﻿@{
    Layout = null;
}

@using ZHJ.PerfectOA.Model
@model ZHJ.PerfectOA.Model.UserInfo
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>SetUserActionInfo</title>
    <link href="~/Content/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <link href="~/Content/tableStyle.css" rel="stylesheet" />
    
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.easyui.min.js"></script>
    <script src="~/Scripts/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".selectActions").click(function () {
               // var userId=
                $.post("/UserInfo/SetUserActionInfo", {
                    "userId": "@Model.ID", "actionId": $(this
                    ).attr("ids"),"value":$(this).val()}, function (data) {
                        if (data == "ok") {
                            $.messager.show({
                                title: '提示',
                                msg: '分配成功',
                                showType: 'show'
                            });
                        }
                        else {
                            $.messager.show({
                                title: '提示',
                                msg: '分配失败!!',
                                showType: 'show'
                            });
                        }
                });
            });
            $(".btnClear").click(function () {
                var $control = $(this);
                $.post("/UserInfo/RemoveUserAction", {
                    "userId": "@Model.ID", "actionId": $(this
                        ).attr("ids")
                }, function (data) {
                    if (data == "ok") {
                        $control.parent().find(".selectActions").removeAttr("checked");
                        $.messager.show({
                            title: '提示',
                            msg: '清除成功',
                            showType: 'show'
                        });
                    }
                    else {
                        $.messager.show({
                            title: '提示',
                            msg: '清除失败!!',
                            showType: 'show'
                        });
                    }
                });
            });


        });

    </script>

</head>
<body>
    <div>
        为用户
        @{
            <span style="font-size:16px;color:red">@Model.UName</span>
        }分配权限

        <table>
            <tr><th>权限编号</th><th>权限名称</th><th>地址</th><th>请求方式</th><th>操作</th></tr>
            @using (Ajax.BeginForm("SetUserActionInfo", "UserInfo", new { }, new AjaxOptions() { }, new { id = "setActionForm" }))
            {

                List<ActionInfo> actionInfoList = ViewBag.AllActionInfo;
                List<R_UserInfo_ActionInfo> r_userInfo_ActionInfoList = ViewBag.AllActionId;
                foreach (ActionInfo actionInfo in actionInfoList)
                {
                    <tr>
                        <td>@actionInfo.ID</td>
                        <td>@actionInfo.ActionInfoName</td>
                        <td>@actionInfo.Url</td>
                        <td>@actionInfo.HttpMethod</td>
                        <td>
                            @{
                    var rb = "rb_" + actionInfo.ID;
                    //var norb = "norb_" + actionInfo.ID;
                    var isExt = (from r in r_userInfo_ActionInfoList
                                 where r.ActionInfoID == actionInfo.ID
                                 select r).FirstOrDefault();
                    if (isExt != null)
                    {
                        if (isExt.IsPass == true)
                        {
                            <label for="@rb">允许</label>
                                <input type="radio" name="@rb" checked="checked" ids="@actionInfo.ID" class="selectActions" value="true" />
                                <label for="@rb">拒绝</label>
                                <input type="radio" name="@rb" ids="@actionInfo.ID" class="selectActions" value="false" />
                        }
                        else
                        {
                            <label for="@rb">允许</label>
                                <input type="radio" name="@rb" ids="@actionInfo.ID" class="selectActions" value="true" />
                                <label for="@rb">拒绝</label>
                                <input type="radio" name="@rb" checked="checked" ids="@actionInfo.ID" class="selectActions" value="false" />
                        }
                    }
                    else
                    {
                        <label for="@rb">允许</label>
                                <input type="radio" name="@rb" ids="@actionInfo.ID" class="selectActions" value="true" />
                                <label for="@rb">拒绝</label>
                                <input type="radio" name="@rb" ids="@actionInfo.ID" class="selectActions" value="false" />
                    }
                    <input type="button" value="清除" class="btnClear" ids="@actionInfo.ID" />
                            }

                        </td>
                    </tr>
                }


            }
        </table>

    </div>

</body>
</html>
